package com.qfedu.controller;

import com.qfedu.entity.Address;
import com.qfedu.entity.User;
import com.qfedu.service.AddressService;
import com.qfedu.service.impl.AddressServiceImpl;
import com.qfedu.utils.BaseServlet;
import com.qfedu.utils.Constants;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@WebServlet("/address.do")
public class AddressServletDo extends BaseServlet {
    private AddressService addressService = new AddressServiceImpl();

    /**
     * 查询所有收货地址
     *
     * @param request
     * @param response
     * @return
     */
    public String show(HttpServletRequest request, HttpServletResponse response) {
        User loginUser = (User) request.getSession().getAttribute("loginUser");
        int uid = loginUser.getUid();
        if (uid > 0) {
            List<Address> list = addressService.findAddressById(uid);
            request.setAttribute("list", list);

        }
        return Constants.FORWARD + "/self_info.jsp";
    }
}
